const pageConf = {
    extends: extendsQ,
    data() {
        return {
            // tab 切换值
            tabActiveName: "djjl",
            // tab 列表
            tabList: [
                { label: '待检记录', name: 'djjl' },
                { label: '已检记录', name: 'yjjl' }
            ],

            // 申请编号
            insAppNumber: "",
            // 状态选中列表
            insState: [],
            // 状态列表
            insStateOptions: [
                { label: "申请中", value: 1 },
                { label: "已拒绝", value: 4 },
                { label: "已接收", value: 2 }
            ],
            // 待检记录表格数据
            inspectedTableData: [],
            // 待检记录分页
            inspectedPagination: {
                currentPage: "1",
                pageSizes: [20, 40, 60],
                pageSize: "20",
                total: 0
            },
            // 表格加载动画
            tableLoading: false,

            // 检测页传数据
            dataOptions: {},

            // 是否显示检测页
            showTestPage: false,
            // 检测页传参
            dialogSource: 1,
            // 开始检测所属稻种列表
            seedRiceList: []
        }
    },
    computed: {

    },
    methods: {
        /**
         * tab 切换
         */
        handleTabClick() {

        },
        /**
         * 修改状态方法  
         * @param { Number } status  要修改的状态
         * @param { Number } id  要修改的列表
         * @param { * } reason  原因
         * @param { * } info    弹框信息
         * @param { Function } callback   回调
         * status:2-已接收、3-已检测、4-不予检测、5-已发布、6-已撤回发布、7-用户撤销申请,=4时传reason
         */
        modifyStatus(status, id, reason = "", info, callback) {
            let params = { "id": id, "status": status, "reason": reason, current_user_id: GLOBAL_CONFIG.userId() }
            tpHttp.post(this, "action=com.top.riceInstitute.QualityRiceEvaluateInfo.editStatus", { param: JSON.stringify(params) }, (data, code, message) => {
                if (code == 0) {
                    let message = (info || "修改状态") + "成功"
                    this.$message.success(message)
                    callback()
                } else {
                    let ermessage = (info || "修改状态") + "失败"
                    this.$message.error(ermessage)
                }
            })
        },
        /**
         * 头部搜索表格
         * input 失去焦点 | 下拉框改变 触发
         */
        headSearchTable() {
            this.inspectedPagination.currentPage = 1;
            this.getInspectedTableDataList();
        },
        /**
         * 添加检测点击
         */
        addTestHandle() {
            this.dialogSource = 1;
            this.dataOptions = {};
            this.showTestPage = true;
        },
        /**
         * 获取待检记录表格数据
         */
        getInspectedTableDataList() {
            this.tableLoading = true
            let status = this.insState?.length ? this.insState.join(",") : "1,4,2";
            let params = { "page": this.inspectedPagination.currentPage, "size": this.inspectedPagination.pageSize, "status": status, "user_id": GLOBAL_CONFIG.userId(), "apply_number": this.insAppNumber }
            tpHttp.post(this, "action=com.top.riceInstitute.QualityRiceEvaluateInfo.search", { param: JSON.stringify(params) }, (data, code, message) => {
                if (code == 0 && data?.list?.length) {
                    this.inspectedTableData = data.list;
                    this.inspectedPagination.total = Number(data.total) || 0;
                } else {
                    this.inspectedTableData = []
                }
                this.tableLoading = false
            })
        },
        /**
         * 待检记录接收点击
         */
        receiveClick(item) {
            this.$confirm('您确定要接收吗？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.modifyStatus(2, item.id, "", "接收", this.getInspectedTableDataList)
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消接收'
                });
            });

        },
        /**
         * 待检记录开始检测点击
         */
        startTestClick(item) {
            this.dialogSource = 2;
            this.showTestPage = true;
            this.dataOptions = {};
            this.$nextTick(() => {
                this.dataOptions = item;
            })
        },
        /**
         * 待检记录不予检测点击
         */
        noGaugeClick(item) {
            this.$prompt('不予检测原因：', '确定不接收该检测吗？', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPattern: /\S/,
                inputErrorMessage: '请输入原因'
            }).then(({ value }) => {
                this.modifyStatus(4, item.id, value, "拒收", this.getInspectedTableDataList)
            }).catch(() => {
            });
        },
        /**
         * 待检记录分页每页条数切换
         * @param { Number } val 
         */
        inspectedHandleSizeChange(val) {
            this.inspectedPagination.pageSize = val;
            this.getInspectedTableDataList();
        },
        /**
         * 待检记录分页页数切换
         * @param { Number } val 
         */
        inspectedHandleCurrentChange(val) {
            this.inspectedPagination.currentPage = val;
            this.getInspectedTableDataList();
        },


        /**
         * 开始检测页面返回点击
         */
        testBackClick() {
            this.showTestPage = false;
        },
        /**
         * 开始检测页面 评价弹框确认点击
         */
        testResultDefinHandle() {
            window.location.href = "./inspected-records.html"
        }
    },
    mounted() {
        // 获取待检记录表格数据
        this.getInspectedTableDataList();
    }
}